package com.zjitc.controller;

import com.zjitc.daomain.User;
import com.zjitc.service.Userservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class UserController {
    @Autowired
    private Userservice userservice;


    @RequestMapping("/user-save")
    public String save(){
        userservice.save();
        return "save.jsp";
    }

    @RequestMapping("/user-save2")
    public ModelAndView save2(){
        ModelAndView modelAndView =new ModelAndView();
        modelAndView.addObject("username","itheima");
        modelAndView.setViewName("save.jsp");
    return modelAndView;
    }

    @RequestMapping("/user-save3")
    @ResponseBody
    public User save3(){
        User user=new User();
        user.setAge(1);
        user.setName("UserName");
        return user;
    }

}
